package com.a01_2021.thousandstimes.general.service.impl;

import com.a01_2021.thousandstimes.general.entity.Credential;
import com.a01_2021.thousandstimes.general.mapper.CredentialMapper;
import com.a01_2021.thousandstimes.general.service.CredentialService;
import com.a01_2021.thousandstimes.utils.AjaxResponse;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: thousandstimes
 * @description:
 * @author: FRQ
 * @create: 2021-04-02 16:06
 **/
@Service
public class CredentialServiceImpl extends ServiceImpl<CredentialMapper, Credential> implements CredentialService {

    @Autowired
    private CredentialMapper credentialMapper;

    @Override
    public AjaxResponse getCredentialByCategory(String category) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("category",category);
        List<Credential> credentials = credentialMapper.selectList(queryWrapper);
        return AjaxResponse.success(credentials);
    }

    @Override
    @DS("master")
    public Credential getCredentialById(Integer id) {
        Credential credential = credentialMapper.selectById(id);
        return credential;
    }
}
